//
//  HomeHeaderView.swift
//  LiteAccount
//
//  Created by 刘伟 on 2017/5/5.
//  Copyright © 2017年 刘伟. All rights reserved.
//

import UIKit

class HomeHeaderView: UICollectionReusableView {
    
    
    var data: AccountModel? {
        didSet {
            if let currentData = data {
                amountLabel.text = String(format: "%.2f", currentData.amount)
                let note = (currentData.note == "") ? "保持理财习惯，才能保持财富" : currentData.note
                noteLabel.text = "心情：" + note
            }
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: .zero)
        prepareUI()
        layoutUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate func prepareUI() {
        self.backgroundColor = UIColor.la_app
        self.addSubview(titleLabel)
        self.addSubview(amountLabel)
        self.addSubview(noteLabel)
    }
    
    fileprivate func layoutUI() {
        titleLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(5)
            make.height.equalTo(15)
        }
        amountLabel.snp.makeConstraints { (make) in
            make.top.equalTo(titleLabel.snp.bottom).offset(5)
            make.centerX.equalToSuperview()
            make.height.equalTo(60)
        }
        noteLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.height.equalTo(15)
            make.bottom.equalTo(-15)
        }
    }
    
    lazy var titleLabel: UILabel = {
        let object = UILabel()
        object.textColor = .white
        object.font = UIFont.la_Font(ofSize: 12)
        object.textAlignment = .center
        object.text = ""
        return object
    }()
    
    lazy var amountLabel: UILabel = {
        let object = UILabel()
        object.textColor = .white
        object.font = UIFont.la_Font(ofSize: 55)
        object.textAlignment = .center
        object.text = "2999999.00"
        return object
    }()
    
    lazy var noteLabel: UILabel = {
        let object = UILabel()
        object.textColor = .white
        object.font = UIFont.la_Font(ofSize: 15)
        object.textAlignment = .center
        object.text = "心情："
        return object
    }()
    
}
